package com.tgy.基础学习.Thread.Normal;

/**
 * @author 送你一块二向箔
 * @date 2021/11/08 14:59
 */
/*守护线程测试
 */
public class DaemonThread {
    public static void main(String[] args) {

        //用户线程
        Thread prople = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("用户线程运行"+i);
            }
            System.out.println("用户线程停止");
        });

        //守护线程
        Thread god = new Thread(() -> {
            while (true) {
                System.out.println("守护线程运行");
            }

        });
        god.setDaemon(true);

        prople.start();
        god.start();
    }
}
